package qe.spider;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import com.google.gson.Gson;
import qe.spider.cfg.Factor;
import qe.spider.cfg.TradeConfig;
import qe.spider.cfg.TradeHuaXinCfg;
import qe.spider.trade.huaxin.StockTradeHuaXin;
import qe.spider.trade.ths_lanzi.StockTradeTHSLanZi;
import qe.spider.trade.vo.Funds;
import qe.spider.trade.vo.Order;
import qe.spider.vo.Stock;

import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;

public class Test {

    public static void run() {
        System.out.println(DateUtil.now());
    }

    public static void main(String[] args) throws IOException, InterruptedException {

//        BigDecimal price = new BigDecimal("22.2");
//        Integer t = BigDecimal.valueOf(80000).divide(price.multiply(BigDecimal.valueOf(100)), 0, RoundingMode.HALF_UP).intValue() * 100;
//        System.out.println(t);
//        StockTradeHuaXin huaXin = StockTradeHuaXin.init("00646531", "63304162");
//        Thread.sleep(20000);
//        Funds funds = huaXin.queryFund();
//
//        List<Order> orders = huaXin.queryOrder();
//        System.out.println(funds);
//        System.out.println(orders);
//        System.out.println(huaXin.queryPositions());
//        Stock stock = new Stock().code("603131").name("上海沪工");
//        stock.setJiage("15.30");
//        huaXin.buy(stock);
//        StockTradeTHSLanZi ths = new StockTradeTHSLanZi("95181294");
//        ths.buy(stock);
//        ths.queryFund();
//        ths.queryPositions();
        System.out.println(IdUtil.fastSimpleUUID());
        System.out.println(IdUtil.fastUUID());
        System.out.println(IdUtil.objectId());
        System.out.println(IdUtil.nanoId());
        System.out.println(IdUtil.nanoId(32));

        Factor factor = new Factor();
        TradeHuaXinCfg xw = TradeHuaXinCfg.builder().userName("谢炜华鑫模拟账号").userId("00646531").password("63304162").maxBuyCntPerDay(1).buyStrategy("shangbang_buy").sellStrategy("fall_avg_sell").build();
        TradeHuaXinCfg xf = TradeHuaXinCfg.builder().userName("徐樊华鑫模拟账号").userId("00361630").password("95094485").maxBuyCntPerDay(10).buyStrategy("zhangting_buy").sellStrategy("fall_avg_sell").build();
        factor.getOthers().setTradeConfig(TradeConfig.builder().maxBuyCntPerDay(10).tradeHuaXinCfgList(List.of(xw, xf)).build());
        System.out.println(new Gson().toJson(factor.getOthers()));
    }
}
